using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace sharpTV.Entities
{
	/// <summary>
	/// Strongly-typed collection for the Culture class.
	/// </summary>
    [Serializable]
	public partial class CultureCollection : ActiveList<Culture, CultureCollection>
	{	   
		public CultureCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>CultureCollection</returns>
		public CultureCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                Culture o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the sharpTV_Cultures table.
	/// </summary>
	[Serializable]
	public partial class Culture : ActiveRecord<Culture>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public Culture()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public Culture(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public Culture(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public Culture(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("sharpTV_Cultures", TableType.Table, DataService.GetInstance("sharpTVSubSonicProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarCultureId = new TableSchema.TableColumn(schema);
				colvarCultureId.ColumnName = "CultureId";
				colvarCultureId.DataType = DbType.Int32;
				colvarCultureId.MaxLength = 0;
				colvarCultureId.AutoIncrement = true;
				colvarCultureId.IsNullable = false;
				colvarCultureId.IsPrimaryKey = true;
				colvarCultureId.IsForeignKey = false;
				colvarCultureId.IsReadOnly = false;
				colvarCultureId.DefaultSetting = @"";
				colvarCultureId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCultureId);
				
				TableSchema.TableColumn colvarCultureUId = new TableSchema.TableColumn(schema);
				colvarCultureUId.ColumnName = "CultureUId";
				colvarCultureUId.DataType = DbType.Guid;
				colvarCultureUId.MaxLength = 0;
				colvarCultureUId.AutoIncrement = false;
				colvarCultureUId.IsNullable = true;
				colvarCultureUId.IsPrimaryKey = false;
				colvarCultureUId.IsForeignKey = false;
				colvarCultureUId.IsReadOnly = false;
				
						colvarCultureUId.DefaultSetting = @"(newid())";
				colvarCultureUId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCultureUId);
				
				TableSchema.TableColumn colvarDisplayName = new TableSchema.TableColumn(schema);
				colvarDisplayName.ColumnName = "DisplayName";
				colvarDisplayName.DataType = DbType.String;
				colvarDisplayName.MaxLength = 64;
				colvarDisplayName.AutoIncrement = false;
				colvarDisplayName.IsNullable = true;
				colvarDisplayName.IsPrimaryKey = false;
				colvarDisplayName.IsForeignKey = false;
				colvarDisplayName.IsReadOnly = false;
				colvarDisplayName.DefaultSetting = @"";
				colvarDisplayName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDisplayName);
				
				TableSchema.TableColumn colvarEnglishName = new TableSchema.TableColumn(schema);
				colvarEnglishName.ColumnName = "EnglishName";
				colvarEnglishName.DataType = DbType.String;
				colvarEnglishName.MaxLength = 64;
				colvarEnglishName.AutoIncrement = false;
				colvarEnglishName.IsNullable = true;
				colvarEnglishName.IsPrimaryKey = false;
				colvarEnglishName.IsForeignKey = false;
				colvarEnglishName.IsReadOnly = false;
				colvarEnglishName.DefaultSetting = @"";
				colvarEnglishName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEnglishName);
				
				TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
				colvarName.ColumnName = "Name";
				colvarName.DataType = DbType.String;
				colvarName.MaxLength = 64;
				colvarName.AutoIncrement = false;
				colvarName.IsNullable = true;
				colvarName.IsPrimaryKey = false;
				colvarName.IsForeignKey = false;
				colvarName.IsReadOnly = false;
				colvarName.DefaultSetting = @"";
				colvarName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarName);
				
				TableSchema.TableColumn colvarISO2CharsName = new TableSchema.TableColumn(schema);
				colvarISO2CharsName.ColumnName = "ISO2CharsName";
				colvarISO2CharsName.DataType = DbType.String;
				colvarISO2CharsName.MaxLength = 2;
				colvarISO2CharsName.AutoIncrement = false;
				colvarISO2CharsName.IsNullable = true;
				colvarISO2CharsName.IsPrimaryKey = false;
				colvarISO2CharsName.IsForeignKey = false;
				colvarISO2CharsName.IsReadOnly = false;
				colvarISO2CharsName.DefaultSetting = @"";
				colvarISO2CharsName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarISO2CharsName);
				
				TableSchema.TableColumn colvarISO3CharsName = new TableSchema.TableColumn(schema);
				colvarISO3CharsName.ColumnName = "ISO3CharsName";
				colvarISO3CharsName.DataType = DbType.String;
				colvarISO3CharsName.MaxLength = 3;
				colvarISO3CharsName.AutoIncrement = false;
				colvarISO3CharsName.IsNullable = true;
				colvarISO3CharsName.IsPrimaryKey = false;
				colvarISO3CharsName.IsForeignKey = false;
				colvarISO3CharsName.IsReadOnly = false;
				colvarISO3CharsName.DefaultSetting = @"";
				colvarISO3CharsName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarISO3CharsName);
				
				TableSchema.TableColumn colvarCurrencySymbol = new TableSchema.TableColumn(schema);
				colvarCurrencySymbol.ColumnName = "CurrencySymbol";
				colvarCurrencySymbol.DataType = DbType.String;
				colvarCurrencySymbol.MaxLength = 8;
				colvarCurrencySymbol.AutoIncrement = false;
				colvarCurrencySymbol.IsNullable = true;
				colvarCurrencySymbol.IsPrimaryKey = false;
				colvarCurrencySymbol.IsForeignKey = false;
				colvarCurrencySymbol.IsReadOnly = false;
				colvarCurrencySymbol.DefaultSetting = @"";
				colvarCurrencySymbol.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCurrencySymbol);
				
				TableSchema.TableColumn colvarCurrencyName = new TableSchema.TableColumn(schema);
				colvarCurrencyName.ColumnName = "CurrencyName";
				colvarCurrencyName.DataType = DbType.String;
				colvarCurrencyName.MaxLength = 32;
				colvarCurrencyName.AutoIncrement = false;
				colvarCurrencyName.IsNullable = true;
				colvarCurrencyName.IsPrimaryKey = false;
				colvarCurrencyName.IsForeignKey = false;
				colvarCurrencyName.IsReadOnly = false;
				colvarCurrencyName.DefaultSetting = @"";
				colvarCurrencyName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCurrencyName);
				
				TableSchema.TableColumn colvarCurrecyCode = new TableSchema.TableColumn(schema);
				colvarCurrecyCode.ColumnName = "CurrecyCode";
				colvarCurrecyCode.DataType = DbType.String;
				colvarCurrecyCode.MaxLength = 32;
				colvarCurrecyCode.AutoIncrement = false;
				colvarCurrecyCode.IsNullable = true;
				colvarCurrecyCode.IsPrimaryKey = false;
				colvarCurrecyCode.IsForeignKey = false;
				colvarCurrecyCode.IsReadOnly = false;
				colvarCurrecyCode.DefaultSetting = @"";
				colvarCurrecyCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCurrecyCode);
				
				TableSchema.TableColumn colvarIsRightToLeft = new TableSchema.TableColumn(schema);
				colvarIsRightToLeft.ColumnName = "IsRightToLeft";
				colvarIsRightToLeft.DataType = DbType.Boolean;
				colvarIsRightToLeft.MaxLength = 0;
				colvarIsRightToLeft.AutoIncrement = false;
				colvarIsRightToLeft.IsNullable = true;
				colvarIsRightToLeft.IsPrimaryKey = false;
				colvarIsRightToLeft.IsForeignKey = false;
				colvarIsRightToLeft.IsReadOnly = false;
				colvarIsRightToLeft.DefaultSetting = @"";
				colvarIsRightToLeft.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsRightToLeft);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["sharpTVSubSonicProvider"].AddSchema("sharpTV_Cultures",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("CultureId")]
		[Bindable(true)]
		public int CultureId 
		{
			get { return GetColumnValue<int>(Columns.CultureId); }
			set { SetColumnValue(Columns.CultureId, value); }
		}
		  
		[XmlAttribute("CultureUId")]
		[Bindable(true)]
		public Guid? CultureUId 
		{
			get { return GetColumnValue<Guid?>(Columns.CultureUId); }
			set { SetColumnValue(Columns.CultureUId, value); }
		}
		  
		[XmlAttribute("DisplayName")]
		[Bindable(true)]
		public string DisplayName 
		{
			get { return GetColumnValue<string>(Columns.DisplayName); }
			set { SetColumnValue(Columns.DisplayName, value); }
		}
		  
		[XmlAttribute("EnglishName")]
		[Bindable(true)]
		public string EnglishName 
		{
			get { return GetColumnValue<string>(Columns.EnglishName); }
			set { SetColumnValue(Columns.EnglishName, value); }
		}
		  
		[XmlAttribute("Name")]
		[Bindable(true)]
		public string Name 
		{
			get { return GetColumnValue<string>(Columns.Name); }
			set { SetColumnValue(Columns.Name, value); }
		}
		  
		[XmlAttribute("ISO2CharsName")]
		[Bindable(true)]
		public string ISO2CharsName 
		{
			get { return GetColumnValue<string>(Columns.ISO2CharsName); }
			set { SetColumnValue(Columns.ISO2CharsName, value); }
		}
		  
		[XmlAttribute("ISO3CharsName")]
		[Bindable(true)]
		public string ISO3CharsName 
		{
			get { return GetColumnValue<string>(Columns.ISO3CharsName); }
			set { SetColumnValue(Columns.ISO3CharsName, value); }
		}
		  
		[XmlAttribute("CurrencySymbol")]
		[Bindable(true)]
		public string CurrencySymbol 
		{
			get { return GetColumnValue<string>(Columns.CurrencySymbol); }
			set { SetColumnValue(Columns.CurrencySymbol, value); }
		}
		  
		[XmlAttribute("CurrencyName")]
		[Bindable(true)]
		public string CurrencyName 
		{
			get { return GetColumnValue<string>(Columns.CurrencyName); }
			set { SetColumnValue(Columns.CurrencyName, value); }
		}
		  
		[XmlAttribute("CurrecyCode")]
		[Bindable(true)]
		public string CurrecyCode 
		{
			get { return GetColumnValue<string>(Columns.CurrecyCode); }
			set { SetColumnValue(Columns.CurrecyCode, value); }
		}
		  
		[XmlAttribute("IsRightToLeft")]
		[Bindable(true)]
		public bool? IsRightToLeft 
		{
			get { return GetColumnValue<bool?>(Columns.IsRightToLeft); }
			set { SetColumnValue(Columns.IsRightToLeft, value); }
		}
		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(Guid? varCultureUId,string varDisplayName,string varEnglishName,string varName,string varISO2CharsName,string varISO3CharsName,string varCurrencySymbol,string varCurrencyName,string varCurrecyCode,bool? varIsRightToLeft)
		{
			Culture item = new Culture();
			
			item.CultureUId = varCultureUId;
			
			item.DisplayName = varDisplayName;
			
			item.EnglishName = varEnglishName;
			
			item.Name = varName;
			
			item.ISO2CharsName = varISO2CharsName;
			
			item.ISO3CharsName = varISO3CharsName;
			
			item.CurrencySymbol = varCurrencySymbol;
			
			item.CurrencyName = varCurrencyName;
			
			item.CurrecyCode = varCurrecyCode;
			
			item.IsRightToLeft = varIsRightToLeft;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varCultureId,Guid? varCultureUId,string varDisplayName,string varEnglishName,string varName,string varISO2CharsName,string varISO3CharsName,string varCurrencySymbol,string varCurrencyName,string varCurrecyCode,bool? varIsRightToLeft)
		{
			Culture item = new Culture();
			
				item.CultureId = varCultureId;
			
				item.CultureUId = varCultureUId;
			
				item.DisplayName = varDisplayName;
			
				item.EnglishName = varEnglishName;
			
				item.Name = varName;
			
				item.ISO2CharsName = varISO2CharsName;
			
				item.ISO3CharsName = varISO3CharsName;
			
				item.CurrencySymbol = varCurrencySymbol;
			
				item.CurrencyName = varCurrencyName;
			
				item.CurrecyCode = varCurrecyCode;
			
				item.IsRightToLeft = varIsRightToLeft;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn CultureIdColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn CultureUIdColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn DisplayNameColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn EnglishNameColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn NameColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        public static TableSchema.TableColumn ISO2CharsNameColumn
        {
            get { return Schema.Columns[5]; }
        }
        
        
        
        public static TableSchema.TableColumn ISO3CharsNameColumn
        {
            get { return Schema.Columns[6]; }
        }
        
        
        
        public static TableSchema.TableColumn CurrencySymbolColumn
        {
            get { return Schema.Columns[7]; }
        }
        
        
        
        public static TableSchema.TableColumn CurrencyNameColumn
        {
            get { return Schema.Columns[8]; }
        }
        
        
        
        public static TableSchema.TableColumn CurrecyCodeColumn
        {
            get { return Schema.Columns[9]; }
        }
        
        
        
        public static TableSchema.TableColumn IsRightToLeftColumn
        {
            get { return Schema.Columns[10]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string CultureId = @"CultureId";
			 public static string CultureUId = @"CultureUId";
			 public static string DisplayName = @"DisplayName";
			 public static string EnglishName = @"EnglishName";
			 public static string Name = @"Name";
			 public static string ISO2CharsName = @"ISO2CharsName";
			 public static string ISO3CharsName = @"ISO3CharsName";
			 public static string CurrencySymbol = @"CurrencySymbol";
			 public static string CurrencyName = @"CurrencyName";
			 public static string CurrecyCode = @"CurrecyCode";
			 public static string IsRightToLeft = @"IsRightToLeft";
						
		}
		#endregion
		
		#region Update PK Collections
		
        #endregion
    
        #region Deep Save
		
        #endregion
	}
}
